//
//  JXVideoRecordPlayTool.h
//  JXIntercomSDK
//
//  Created by Nansen on 2021/8/5.
//  Copyright © 2021 jingxi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "JXIntercomConstants.h"

@class JXVideoRecordModel;
@class CATiledLayer;

NS_ASSUME_NONNULL_BEGIN

@protocol JXVideoRecordPlayDelegate <NSObject>

@optional
/// 获得此录像的总时长. play 之后会收到此回调.
/// @param duration 时长. 毫秒.
- (void)recordPlayDidGetVideoDuration:(NSInteger)duration;

/// 录像的视频尺寸
/// @param size 视频尺寸
- (void)recordPlayDidChangeLayerSize:(CGSize)size;

/// 播放进度
/// @param playTime 已播放的时长. 毫秒
/// @param totalTime 总时长. 毫秒
- (void)recordPlayDidPlayProgress:(NSInteger)playTime totalTime:(NSInteger)totalTime;

/// 播放完成
- (void)recordPlayDidPlayCompleted;

@end


@interface JXVideoRecordPlayTool : NSObject

@property (nonatomic, weak, nullable) id<JXVideoRecordPlayDelegate> delegate;

@property (nonatomic, strong) JXVideoRecordModel *videoRecord;

@property (nonatomic, assign, readonly) BOOL isPlaying;

/// 初始化
- (instancetype)initWithVideoRecord:(JXVideoRecordModel *)videoRecord
                           delegate:(id<JXVideoRecordPlayDelegate>)delegate;



/// 播放录像
/// @param videoLayer 必须是 CATiledLayer
/// 返回值: JX_IntercomResultType_IncorrectParam - 未传 videoLayer 参数.
///       JX_IntercomResultType_NoFile - 录像文件已不存在
- (JX_IntercomResultType)playOnLayer:(CATiledLayer *)videoLayer;

/// 停止播放录像, 不是暂停
- (void)stop;

/// 调整播放的进度
/// @param progress 百分比进度, 比如 80%, progress=80
- (void)seekProgress:(int)progress;


@end

NS_ASSUME_NONNULL_END
